<!DOCTYPE html>
<html lang="en" style="width:100%;height:100%;">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>管理端—姑苏区企业复工网上服务平台</title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="css/login.css">
    <link rel="stylesheet" href="css/base.css">
    <script src="css/jquery.min.js"></script>
    <script src="js/0_common/bootstrap.js"></script>
    <script src="js/0_common/common.js"></script>
    <script src="js/constants.js"></script>

    <!--<script src="js/0_common/echarts-all.js"></script>-->
</head>
<style>
    #wj:hover{
        cursor: pointer;
    }
    /*#djlogin:hover{*/
    /*cursor: pointer;*/
    /*background-image: url("img/dllogin.png");*/
    /*background-size: 100% 100%;*/
    /*height:32px;*/
    /*}*/
    #djlogin{
        cursor: pointer;
        background-image: url("img/dllogin.png");
        background-size: 100% 100%;
        height:32px;
    }
    /*#user{*/
    /*color:#C3C4C5;*/
    /*}*/
    /*#mm{*/
    /*color:#C3C4C5;*/
    /*}*/
    /*::-webkit-input-placeholder{!*Webkit browsers*!*/
    /*color:white!important;*/
    /*}*/
    .input-val {
        width: 28%;
        height: 32px;
        box-sizing: border-box;
        line-height: 1.42857143;
        color: #555;
        background-color: #fff;
        background-image: none;
        border: 1px solid #ccc;
        border-radius: 4px;
    }
    #canvas {
        vertical-align: middle;
        box-sizing: border-box;
        border: 1px solid #ccc;
        border-radius: 4px;
        cursor: pointer;
        margin-top: -5px;
    }
    #login{
        width: 25%;
        height: 50%;
        position: absolute;
        top:22%;
        left:70%;
        background-image: url("img/dl.png");
        background-size: 100% 100%;
    }
    #login input{
        background:rgba(219,220,226,1);
        border:2px solid rgba(255, 255, 255, 1);
        border-radius:5px;
    }
    .line_m{
        text-decoration:line-through;
        color: #A6A9B2;
    }
</style>
<body style="width:100%;height:100%;background-image: url('img/tempGLbg.png');background-size: 100% 100%;">
<div id="login">
    <!--<div style="width:55%;margin-left: 23%;margin-top: 31%">-->
    <div style="width:55%;position: relative;top:30%;left:26%">
        <span style="font-size:14px;font-family:Source Han Sans CN;font-weight:400;color:rgba(255,255,255,1);line-height:30px;display:inline-block">用户名&nbsp;&nbsp;</span>
        <input type="text" class="form-control" placeholder="" style="width:65%;height:32px;display:inline-block" id="user">
    </div>
    <div style="width:55%;position: relative;top:32%;left:26%">
        <!--<div style="width:55%;margin-left: 23%;margin-top: 43%">-->
        <span style="font-size:14px;font-family:Source Han Sans CN;font-weight:400;color:rgba(255,255,255,1);line-height:30px">密&nbsp;&nbsp;&nbsp;码&nbsp;&nbsp;</span>
        <input type="password" class="form-control" placeholder="" style="width:65%;height:32px;display:inline-block;margin-left: 1%" id="mm">
    </div><br />
    <div style="width:68%;position: relative;top:31%;left:26%;height:0px">
        <!--<div style="width:65%;margin-left: 23%;margin-top: 55%">-->
        <span style="font-size:14px;font-family:Source Han Sans CN;font-weight:400;color:rgba(255,255,255,1);line-height:30px">验证码&nbsp;&nbsp;</span>
        <input type="text" value="" placeholder="" class="input-val" >
        <canvas id="canvas" width="85" height="30" style="background-color: white"></canvas>
    </div>
    <div style="width:52%;position: relative;top:45%;left:26%;" id="djlogin">
    </div>
</div>
<div style="position: absolute;left:71%;top:73%">
    <div style="margin:0px 70px 20px 70px">
        <span style="color:#a29a9a;font-size: 14px; ">使用chrome浏览器访问效果更佳，请</span>
        <span style="color: #46AFD8;font-size: 14px;cursor: pointer"  onclick="window.location.href = './chrome/ChromeSetup.rar';">下载</span>
    </div>
</div>
</body>
<script>
    sessionStorage.setItem('login', 0);
    var svcHeader=Constants.path;
    var token1=token;
    var p = /[0-9]/; //var b = p.test(string);//true,说明有数字

    var p1 = /[a-z]/i; //var b = p.test(string);//true,说明有英文字母

    var p2 = /[A-Z]/i; //var b = p.test(string);//true,说明有英文字母或数字
    function checkPass(s){

        // if(s.length < 8){
        //
        //     return 0;
        // }
        var ls = 0;

        if(s.match(/([a-z])+/)){

            ls++;

        }

        if(s.match(/([0-9])+/)){

            ls++;
        }

        if(s.match(/([A-Z])+/)){

            ls++;

        }
        if(s.match(/[^a-zA-Z0-9]+/)){

            ls++;

        }
        return ls

    }
    $(function(){
        var show_num = [];
        draw(show_num);
        $("#canvas").on('click',function(){
            draw(show_num);
        })
        $("#djlogin").click(function () {
            var val = $(".input-val").val().toLowerCase();
            var num = show_num.join("");
            if(val==''){
                alert('请输入验证码！');
            }else if(val == num){
                var obj1={
                    'password':$('#mm').val(),
                    'name':$('#user').val()
                };
                $.ajax({
                    url:svcHeader+"shrs/login",
                    dataType: 'json',
                    type: 'POST',
                    data: obj1,
                    success: function (data) {
                        console.log(data)
                        if(data.msg =='success'){
                            data=data.data;
                            localStorage.setItem('qyid',data.id);
                            localStorage.setItem('qymc',data.name);
                            localStorage.setItem('zhen',data.zhen);
                            localStorage.setItem('qu',data.qu);
                            localStorage.setItem('user',JSON.stringify(data));
                            window.location.href="main1.html";
                        }else{
                            alert("登陆失败！")
                        }
                    },
                    error: function (data) {
                        if(data.msg ==success){
                            data=data.data;
                            localStorage.setItem('qyid',data.id);
                            localStorage.setItem('qymc',data.name);
                            window.location.href="main1.html";
                        }else{
                            alert("登陆失败！")
                        }
                    }
                })
                // draw(show_num);
            }else{
                alert('验证码错误！请重新输入！');
                $(".input-val").val('');
                // draw(show_num);
            }

        })
    })
    //生成并渲染出验证码图形
    function draw(show_num) {
        var canvas_width=$('#canvas').width();
        var canvas_height=$('#canvas').height();
        var canvas = document.getElementById("canvas");//获取到canvas的对象，演员
        var context = canvas.getContext("2d");//获取到canvas画图的环境，演员表演的舞台
        canvas.width = canvas_width;
        canvas.height = canvas_height;
        var sCode = "a,b,c,d,e,f,g,h,i,j,k,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,E,F,G,H,J,K,L,M,N,P,Q,R,S,T,W,X,Y,Z,1,2,3,4,5,6,7,8,9,0";
        var aCode = sCode.split(",");
        var aLength = aCode.length;//获取到数组的长度
        for (var i = 0; i < 4; i++) { //这里的for循环可以控制验证码位数（如果想显示6位数，4改成6即可）
            var j = Math.floor(Math.random() * aLength);//获取到随机的索引值
            // var deg = Math.random() * 30 * Math.PI / 180;//产生0~30之间的随机弧度
            var deg = Math.random() - 0.5; //产生一个随机弧度
            var txt = aCode[j];//得到随机的一个内容
            show_num[i] = txt.toLowerCase();
            var x = 10 + i * 20;//文字在canvas上的x坐标
            var y = 20 + Math.random() * 8;//文字在canvas上的y坐标
            context.font = "bold 23px 微软雅黑";
            context.translate(x, y);
            context.rotate(deg);
            context.fillStyle = randomColor();
            context.fillText(txt, 0, 0);
            context.rotate(-deg);
            context.translate(-x, -y);
        }
        for (var i = 0; i <= 5; i++) { //验证码上显示线条
            context.strokeStyle = randomColor();
            context.beginPath();
            context.moveTo(Math.random() * canvas_width, Math.random() * canvas_height);
            context.lineTo(Math.random() * canvas_width, Math.random() * canvas_height);
            context.stroke();
        }
        for (var i = 0; i <= 30; i++) { //验证码上显示小点
            context.strokeStyle = randomColor();
            context.beginPath();
            var x = Math.random() * canvas_width;
            var y = Math.random() * canvas_height;
            context.moveTo(x, y);
            context.lineTo(x + 1, y + 1);
            context.stroke();
        }
    }
    //得到随机的颜色值
    function randomColor() {
        var r = Math.floor(Math.random() * 256);
        var g = Math.floor(Math.random() * 256);
        var b = Math.floor(Math.random() * 256);
        return "rgb(" + r + "," + g + "," + b + ")";
    }
    function browserRedirect() {
        var sUserAgent = navigator.userAgent.toLowerCase();
        var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
        var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
        var bIsMidp = sUserAgent.match(/midp/i) == "midp";
        var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
        var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
        var bIsAndroid = sUserAgent.match(/android/i) == "android";
        var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
        var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
        if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) {
            //跳转移动端页面
            window.location.href=svcHeader+"FangYi/wxlogin.html";

        } else {
            //跳转pc端页面
            // window.location.href=svcHeader+"FangYi/login.html";
        }
    }
    browserRedirect();
</script>
</html>
